package cn.xiaoniu.day01.util;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import cn.xiaoniu.day01.bean.RatingBean;
import cn.xiaoniu.day01.bean.UidAvgBean;

public class SortUtil {
	/**
	 * 排序
	 * @param list
	 */
	public static void sortByRate(List<RatingBean> list) {
		Collections.sort(list,new Comparator<RatingBean>() {

			@Override
			public int compare(RatingBean o1, RatingBean o2) {
				//按照rate进行降序排列
				return o2.getRate()-o1.getRate();
			}
		});
		
	}

	public static void sortByAvg(List<UidAvgBean> list) {
		Collections.sort(list, new Comparator<UidAvgBean>() {

			@Override
			public int compare(UidAvgBean o1, UidAvgBean o2) {
				if(o1.getAvg() == o2.getAvg()){
					return 0;//
				}else{
					return (o2.getAvg()-o1.getAvg())>0?1:-1;
				}
			}
		});
		
	}

}
